import numpy as np
''' 可以自己总结以下，小写字母一般为value type，大写为引用类型。比较特殊的应该是V，这个在Python中比较少见。
i - integer
b - boolean
u - unsigned integer
f - float
c - complex float
m - timedelta
M - datetime
O - object
S - string
U - unicode string
V - fixed chunk of memory for other type ( void )
'''

arr = np.array([1, 2, 3, 4])
print(arr.dtype,type(arr))

arr = np.array(['apple', 'banana', 'cherry'])
print(arr, arr.dtype)

arr = np.array([1, 2, 3, 4], dtype='S')
print(arr,arr.dtype)

arr = np.array([1, 2, 3, 4], dtype='i4')
print(arr,arr.dtype)

arr = np.array(['100', '2', '3'], dtype='i')
print(arr,arr.dtype)

# Converting Data Type
arr = np.array([1.1, 2.1, 3.1])
print(arr,arr.dtype)
newarr = arr.astype('i') #create new array
print(arr,arr.dtype)
print(newarr,newarr.dtype)